package com.jewaton.auth.commons.entity;


import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 操作功能表
 */
@Entity
@Table(name = "OPERATE_AUTH")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class OperateAuth implements java.io.Serializable {
    
    private static final long serialVersionUID = -1706954125067476140L;
    private Long oauthId;
	private String oauthName;
	private String oauthCode;
	private String oauthDesc;
	private Integer meuId;
	private Boolean enabled;
	
	private Set<Permission> permissions = new HashSet<Permission>(0);


    @Id
    @GeneratedValue(strategy = IDENTITY)
	@Column(name = "O_AUTH_ID", unique = true, nullable = false, precision = 10, scale = 0)
    public Long getOauthId() {
        return oauthId;
    }

    public void setOauthId(Long oauthId) {
        this.oauthId = oauthId;
    }
    
	@Column(name = "O_AUTH_NAME", length = 30)
	public String getOauthName() {
	    return oauthName;
	}
	public void setOauthName(String oauthName) {
	    this.oauthName = oauthName;
	}


	@Column(name = "O_AUTH_CODE",unique=true, length = 50)
	public String getOauthCode() {
	    return oauthCode;
	}
	
	public void setOauthCode(String oauthCode) {
	    this.oauthCode = oauthCode;
	}

	
	
	@Column(name = "MENU_ID", length = 10)
	public Integer getMeuId() {
		return meuId;
	}

    public void setMeuId(Integer meuId) {
		this.meuId = meuId;
	}

	@Column(name = "O_AUTH_DESC", length = 100)
	public String getOauthDesc() {
	    return oauthDesc;
	}
	
	public void setOauthDesc(String oauthDesc) {
	    this.oauthDesc = oauthDesc;
	}
	
	@Column(name = "ENABLED", precision = 10, scale = 0)
	public Boolean getEnabled() {
        return enabled;
    }


    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "operateAuth")
	public Set<Permission> getPermissions() {
		return this.permissions;
	}

	public void setPermissions(Set<Permission> permissions) {
		this.permissions = permissions;
	}

}
